<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper search-box-cuesList" style="margin-bottom:10px">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="4" :lg="7" :md="6" :sm="24">
            <a-form-item label="工号">
              <a-input placeholder="请输入工号" v-model="queryParam.workNo"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="4" :lg="7" :md="6" :sm="8">
            <a-form-item label="姓名">
              <a-input placeholder="请输入姓名" v-model="queryParam.realname"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="4" :sm="6">
            <a-form-item label="归属部门">
              <a-select v-model="queryParam.departIds" placeholder="请选择">

                <a-select-option value="">请选择</a-select-option>
                <a-select-option v-for="(item,index) in departList " :value="item.key" :key="index">{{ item.title }}</a-select-option>-->
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="4" :sm="6">
            <a-form-item label="岗位">
              <a-select v-model="queryParam.roleId" placeholder="请选择">

                <a-select-option value="">请选择</a-select-option>
                <a-select-option v-for="(item,index) in roleList " :value="item.id" :key="index">{{ item.roleName }}</a-select-option>-->
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :xl="4" :lg="7" :md="6" :sm="6">
            <span style="float: left;overflow: hidden; margin-left:-40px" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search" title="搜索" shape="circle"></a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px" title="重置" shape="circle"></a-button>
            </span>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <!-- 操作按钮区域 -->
              <!--                <a-button type="primary" icon="download" @click="handleExportXls('用户信息')">导出</a-button>-->
              <a-dropdown v-if="selectedRowKeys.length > 0">
                <a-menu slot="overlay">
                  <a-menu-item key="1" @click="batchDel">
                    <a-icon type="delete" />删除</a-menu-item>
                </a-menu>
              </a-dropdown>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- table区域-begin -->
    <div>

      <a-table ref="table" size="middle" rowKey="id" :columns="columns" :dataSource="dataSource" :pagination="ipagination" :loading="loading" @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)">详情</a> &nbsp;&nbsp;
          <a @click="handleSet(record)">编辑</a>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->
    <user-per-modal ref="userPerModal" @ok="searchQuery"></user-per-modal>
    <user-per-detail-modal ref="userPerDetailModal"></user-per-detail-modal>

  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import UserPerModal from './modules/UserPerModal'
import UserPerDetailModal from './modules/UserPerDetailModal'

import { httpAction, getAction } from '@/api/manage'

export default {
  name: 'UsrUserInfoList',
  mixins: [JeecgListMixin],

  components: {
    UserPerDetailModal,
    UserPerModal
  },
  data() {
    return {
      visible: false,
      description: '用户信息管理页面',
      departList: [],
      roleList: [],
      // 表头
      columns: [
        {
          title: '工号',
          align: 'center',
          dataIndex: 'workNo'
        },
        {
          title: '姓名',
          align: 'center',
          dataIndex: 'realname'
        },
        {
          title: '归属部门',
          align: 'center',
          dataIndex: 'departName'
        },
        {
          title: '岗位',
          align: 'center',
          dataIndex: 'roleName',
          scopedSlots: { customRender: 'roleName' }
        },
        {
          title: '岗位绩效',
          align: 'center',
          dataIndex: 'postPerforms'
        },
        {
          title: '基础薪资',
          align: 'center',
          dataIndex: 'performanceValue'
        },
        {
          title: '薪资属性',
          align: 'center',
          dataIndex: 'salaryName'
        },

        {
          title: '操作',
          align: 'center',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/performance/performanceUser/list',
        delete: '/user/usrUserInfo/delete',
        deleteBatch: '/user/usrUserInfo/deleteBatch',
        exportXlsUrl: 'user/usrUserInfo/exportXls',
        importExcelUrl: 'user/usrUserInfo/importExcel',
        shutdown: '/user/usrUserInfo/shutdownRemark'
      }
    }
  },
  created() {
    this.getDepartList()
    this.getRoleList()
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    getDepartList: function() {
      var url = '/sys/sysDepart/queryTreeList'
      getAction(url).then(res => {
        if (res.success) {
          this.departList = res.result
        }
      })
    },
    handleDetail(record) {
      this.$refs.userPerDetailModal.edit(record)
    },
    handleSet(record) {
      this.$refs.userPerModal.edit(record)
      //this.$refs.userPerModa.visible = true
    },
    getRoleList: function() {
      var url = '/sys/role/queryall'
      getAction(url).then(res => {
        if (res.success) {
          this.roleList = res.result
        }
      })
    },
    shutdownRemark(id, status) {
      var param = {
        userId: id,
        isRemark: status
      }
      getAction(this.url.shutdown, param).then(res => {
        if (res.success) {
          this.loadData(1)
        }
        if (res.code === 510) {
          this.$message.warning(res.message)
        }
      })
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>